//
//  LoadingView.m
//  SSC
//
//  Created by 红沙尘 on 17/6/20.
//  Copyright © 2017年 红沙尘. All rights reserved.
//

#import "LoadingView.h"
#import "AppDelegate.h"
@implementation LoadingView

+ (void)show {
    LoadingView *view = [[LoadingView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    view.tag = 2834081;
    AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
    [app.window addSubview:view];
}

+ (void)diss {
    AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
    [[app.window viewWithTag:2834081] removeFromSuperview];
}

- (id)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        UIView *blackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
        [self addSubview:blackView];
        blackView.center = CGPointMake(frame.size.width/2, frame.size.height/2);
        blackView.backgroundColor = ARGB(0, 0, 0, 0.7);
        blackView.layer.cornerRadius = 4;
        blackView.layer.masksToBounds = YES;
        
        UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
        activity.center = CGPointMake(blackView.frame.size.width/2, blackView.frame.size.height/2);
        [activity startAnimating];
        [blackView addSubview:activity];
    }
    
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
